package com.cjm.connect;

import com.mysql.jdbc.Driver;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;


public class test {
//   1.注册驱动
public static void main(String[] args) throws SQLException {
    //1.注册登录
    Driver driver = new Driver();
//    2.得到连接
    String url = "jdbc:mysql://localhost:3306/connenct";
//    3.将用户名和密码放入对象中
    Properties properties = new Properties();
    properties.setProperty("user", "root");
    properties.setProperty("password", "123456");
    Connection conn = driver.connect(url, properties);
//    3.执行sql
    String sql = "insert into actor values(null,'刘德华','男','1970-10-12','110')";
    Statement statement = conn.createStatement();
    int i=statement.executeUpdate(sql);
    System.out.println(i>0?"成功":"失败");
//    4.关闭流
    statement.close();
    conn.close();
}
}
